package com.common.project.base;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public  class Regex {

    /**
     *  正整数  测试过好用
     * @param str
     * @return
     */
    public  static boolean zhengZhengShu(String str){
        String regEx="^[0-9]*[1-9][0-9]*$";
        boolean matcher = Matcher(regEx, str);
        return matcher;
    }
    /**
     *  身份证 测试过好用
     * @param str
     * @return
     */
    public  static boolean shenFenZheng(String str){
        String regEx="(^[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$)|(^[1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{2}[0-9Xx]$)";

        boolean matcher = Matcher(regEx, str);
        return matcher;
    }
    /**
     *  手机号  测试过好用
     * @param str
     * @return
     */
    public  static boolean shouJiHao(String str){
        String regEx="^((17[0-9])|(14[0-9])|(13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$";
        boolean matcher = Matcher(regEx, str);
        return matcher;
    }

    /**
     *  邮箱  测试过好用
     * @param str
     * @return
     */
    public  static boolean youXiang(String str){
        String regEx="^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
        boolean matcher = Matcher(regEx, str);
        return matcher;
    }

    public static boolean Matcher(String zhengZe,String daiPiPenZiFuChuan){
        Pattern pattern = Pattern.compile(zhengZe);
        Matcher matcher = pattern.matcher(daiPiPenZiFuChuan);
        return matcher.matches();
    }



    public static void main(String[] args) {
        boolean b = youXiang("1367345886@163.com");
        System.out.println(b);
    }
}
